from django.conf import settings
from django.conf.urls.defaults import *
from tagging.views import tagged_object_list
from models import Podcast 
from django.contrib.sites.models import Site

site = Site.objects.get(id=settings.SITE_ID)

info_dict = {
    'queryset': Podcast.published_objects.filter(channel__site = settings.SITE_ID),
    'date_field': 'pub_date',
}

urlpatterns = patterns ('',
    (r'^add/$', 'clapton.apps.podcasts.views.add_edit_podcast'),
    (r'^edit/$', 'clapton.apps.podcasts.views.add_edit_podcast'),
    (r'^add/channel/$', 'clapton.apps.podcasts.views.add_edit_channel'),
    (r'^edit/channel/$', 'clapton.apps.podcasts.views.add_edit_channel'),
    (r'tag/(?P<tag>[^/]+(?u))/$', tagged_object_list,
     dict(model = Podcast, paginate_by = 10, allow_empty = True)),

    # Views for all podcasts
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
     'django.views.generic.date_based.archive_day', dict(info_dict, template_name='podcasts/channel_archive_day.html',
							 extra_context={'site': site,})),
    (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'django.views.generic.date_based.archive_month', 
     dict(info_dict, template_name='podcasts/channel_archive_month.html',
          extra_context={'site': site,})),
    (r'^(?P<year>\d{4})/$', 'django.views.generic.date_based.archive_year', dict(info_dict, make_object_list = True, 
										 template_name = 'podcasts/channel_archive_year.html',
							                         extra_context={'site': site,})),
    (r'^today/$', 'django.views.generic.date_based.archive_today', dict(info_dict, template_name = 'podcasts/channel_archive_day.html',
							                extra_context={'site': site,})),
    (r'^/?$', 'django.views.generic.date_based.archive_index', dict(info_dict, template_name = 'podcasts/channel_archive.html',
							            extra_context={'site': site,})),

    # Individual podcast views
    (r'^(?P<channel>[-\w]+)/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$',
     'clapton.apps.podcasts.views.object_detail'),
    (r'^(?P<channel>[-\w]+)/(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 
     'clapton.apps.podcasts.views.archive_day'),
    (r'^(?P<channel>[-\w]+)/(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'clapton.apps.podcasts.views.archive_month'),
    (r'^(?P<channel>[-\w]+)/(?P<year>\d{4})/$', 'clapton.apps.podcasts.views.archive_year'),
    (r'^(?P<channel>[-\w]+)/today/$', 'clapton.apps.podcasts.views.archive_today'),
    (r'^(?P<channel>[-\w]+)/$', 'clapton.apps.podcasts.views.archive_index'),
)
